#ifndef TUSERDIALOG_H
#define TUSERDIALOG_H

#include "TSkinDialog.h"
#include "TContext.h"
#include "TUser.h"

class QLabel;

namespace Ui {
    class TUserDialog;
}

class TUserDialog : public TSkinDialog
{
    Q_OBJECT

public:
    enum Type
    {
        Add = 0,
        Upadte
    };
    
public:
    explicit TUserDialog(Type type, TUserPointer pUser = TUserPointer(), QWidget *parent = 0);
    ~TUserDialog();

private slots:
    void requestRoleFinished(bool error, QList<TRolePointer> roles);
    void createFinished(bool error, TUserPointer user);
    void updateFinished(bool error, TUserPointer user);

    void doCreate();
    void doUpdate();
    //void onSubmit();

private:
    bool check(Type type);
    
private:
    Ui::TUserDialog *ui;
    TRoleRequesterPointer _roleRequster;
    TUserRequesterPointer _userRequester;
    QList<TRolePointer> _roles;

    //update user
    TUserPointer _user;
};

#endif // TUSERDIALOG_H
